package com.zhou.jiancai.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.zhou.jiancai.R;
import com.zhou.jiancai.ui.MyJCVideoPlayerStandard;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;


/**
 * Created by Administrator on 2017/6/6.
 */

public class NiceViewShowActivity extends AppCompatActivity {


    private MyJCVideoPlayerStandard jcVideoPlayerStandard;
    private int xDelta;
    private int yDelta;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nice_video_activity);
        init();

    }

    private void init() {
        jcVideoPlayerStandard = (MyJCVideoPlayerStandard) findViewById(R.id.videoplayer);
        jcVideoPlayerStandard.setUp("http://tanzi27niu.cdsb.mobi/wps/wp-content/uploads/2017/05/2017-05-17_17-33-30.mp4"
                , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子闭眼睛");
        //jcVideoPlayerStandard.thumbImageView.stImageResource(R.mipmap.ic_launcher);
        Glide.with(NiceViewShowActivity.this)
                .load("http://tanzi27niu.cdsb.mobi/wps/wp-content/uploads/2017/05/2017-05-17_17-30-43.jpg")
                .asBitmap()
                .into(jcVideoPlayerStandard.thumbImageView);

       Button enterTinyWindow= (Button) findViewById(R.id.enterTinyWindow);
        enterTinyWindow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (jcVideoPlayerStandard.isCurrentJcvd()) {
                    jcVideoPlayerStandard.startWindowTiny();




                } else {
                    Toast.makeText(NiceViewShowActivity.this, "要播放后才能进入小窗口", Toast.LENGTH_SHORT).show();
                }

            }
        });





     /*   mNiceVideoPlayer = (NiceVideoPlayer) findViewById(R.id.nice_video_player);
        mNiceVideoPlayer.setPlayerType(NiceVideoPlayer.PLAYER_TYPE_IJK); // or NiceVideoPlayer.PLAYER_NATIVE
        mNiceVideoPlayer.setUp("http://tanzi27niu.cdsb.mobi/wps/wp-content/uploads/2017/05/2017-05-17_17-33-30.mp4", null);
        NiceVideoPlayerController controller = new NiceVideoPlayerController(this);//创建niceviewplayer控制器
        controller.setTitle("mTitle");
        controller.setImage("http://tanzi27niu.cdsb.mobi/wps/wp-content/uploads/2017/05/2017-05-17_17-30-43.jpg");
        mNiceVideoPlayer.setController(controller);//设置控制器*/
    }
    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            return;
        }
        super.onBackPressed();
    }
    @Override
    protected void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }




  /* *//*
   * 进入小窗口模式*//*
    public void enterTinyWindow(View view) {
        if (mNiceVideoPlayer.isPlaying()
                || mNiceVideoPlayer.isBufferingPlaying()
                || mNiceVideoPlayer.isPaused()
                || mNiceVideoPlayer.isBufferingPaused()) {
            mNiceVideoPlayer.enterTinyWindow();
        } else {
            Toast.makeText(this, "要播放后才能进入小窗口", Toast.LENGTH_SHORT).show();
        }
    }*/

}
